import React, { Component } from 'react';

class Temperature extends Component {

    scaleNames = {
        c: 'Celsius',
        f: 'Fahrenheit'
    };

    constructor(props) {
        super(props);
        this.onInputChange = this.onInputChange.bind(this);
    }

    onInputChange(event) {
        this.props.onTemperatureChange(event.target.value);
    }

    render() {
        return (
            <fieldset>
                <legend>Enter temperature in {this.scaleNames[this.props.scale]}:</legend>
                <input
                    value={this.props.temperature}
                    onChange={this.onInputChange} />
            </fieldset>
        );
    }
}

export default Temperature;